package com.studentmanage.manage_student.controller;

import com.studentmanage.api.student.StudentControllerApi;
import com.studentmanage.framework.domain.base.Course;
import com.studentmanage.framework.domain.base.Student;
import com.studentmanage.framework.domain.base.request.QueryStudentRequest;
import com.studentmanage.framework.domain.common.response.QueryResult;
import com.studentmanage.framework.domain.common.response.ResponseResult;
import com.studentmanage.framework.domain.common.response.ResponseValue;
import com.studentmanage.manage_student.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController implements StudentControllerApi {
    @Autowired
    private StudentService studentService;

    @Override
    @GetMapping("/list/{page}/{size}")
    public QueryResult findStudentList(@PathVariable("page")int page, @PathVariable("size")int size, QueryStudentRequest queryStudentRequest) {
        return studentService.findStudentList(page, size, queryStudentRequest);
    }

    @Override
    @PostMapping("/add")
    public ResponseResult addStudent(@RequestBody Student student) {
        return studentService.addStudent(student);
    }

    @Override
    @GetMapping("/get/{id}")
    public ResponseValue<Student> findStudentById(@PathVariable("id") String id) {
        return studentService.findStudentById(id);
    }

    @Override
    @PostMapping("/delete")
    public ResponseResult delStudent(@RequestBody String[] ids) {
        return studentService.delStudent(ids);
    }

    @Override
    @PostMapping("/edit")
    public ResponseResult editStudent(@RequestBody Student student) {
        return studentService.editStudent(student);
    }

}
